Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Invert #if NETSTANDARD* conditional compilation conditions #1079

Merged
merged 2 commits into from
Dec 28, 2023

Conversation

0xced
Copy link
Contributor

@0xced 0xced commented Dec 26, 2023

While conceptually .NET 5, 6, 7, 8 are greater than .NET Standard 2.1 it does not apply to the NETSTANDARD2_1_OR_GREATER macro.

So it's safer to conditionally compile on NETSTANDARD2_0 and assume that the #else branch targets a newer framework where the new bits are available in order not to use the old code path on the newest frameworks.

While conceptually .NET 5, 6, 7, 8 are greater than .NET Standard 2.1 it does not apply to the `NETSTANDARD2_1_OR_GREATER` macro.

So it's safer to conditionally compile on NETSTANDARD2_0 and assume that the #else branch targets a newer framework where the new bits are available in order not to use the old code path on the newest frameworks.
Copy link

netlify bot commented Dec 26, 2023

Deploy Preview for testcontainers-dotnet ready!

Name Link
🔨 Latest commit ed07855
🔍 Latest deploy log https://app.netlify.com/sites/testcontainers-dotnet/deploys/658c595ea20d620008de6e88
😎 Deploy Preview https://deploy-preview-1079--testcontainers-dotnet.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Collaborator

@HofmeisterAn HofmeisterAn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I am curious, how did you run into this issue? If you consume the NuGet dependency, for example, in a net8.0 project, it will use the netstandard2.1 version. In the IDE, for instance in Rider, you can select the target framework (I think its default is netstandard2.0).

Thank you for bringing this to my attention. It is not something I would have expected, TBH, especially considering when I first used the macro years ago (which probably was not mentioned in the MSDN back then).

@0xced
Copy link
Contributor Author

0xced commented Dec 27, 2023

Hmm, I am curious, how did you run into this issue?

Sorry I should have been more clear in my description. This is currently not an issue. This pull request is solely future-proofing the conditional compilation so that if a new target framework is added in the future (I have a plan 😉) then the correct (newest) code will be compiled. This stuff is easy to get wrong, I already fixed it in spectreconsole/spectre.console#563 too.

If you consume the NuGet dependency, for example, in a net8.0 project, it will use the netstandard2.1 version.

Yes, absolutely! This is not an issue for consumers of the Testcontainers packages.

Copy link
Collaborator

@HofmeisterAn HofmeisterAn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks ✌️

@HofmeisterAn HofmeisterAn added the chore A change that doesn't impact the existing functionality, e.g. internal refactorings or cleanups label Dec 28, 2023
@HofmeisterAn HofmeisterAn merged commit 5ca4b6b into testcontainers:develop Dec 28, 2023
9 checks passed
@0xced 0xced deleted the netstandard-conditions branch December 28, 2023 11:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore A change that doesn't impact the existing functionality, e.g. internal refactorings or cleanups
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants